define(["oms_model/model"], function($model){
	
	var Navbar = function(data){
		var _this = this;
		
		this.formatChildrens = function(list){
			var childrens = [];
			for(var i=0;list&&i<list.length;i++){
				childrens[i] = new Navbar(list[i]);
			}
			return childrens;
		}
		
		if(data){
			this.id = data.id;
			//菜单中午名称
			this.alias = data.name;
			//图标
			this.icon = data.icon;
			//配置表里的参数
			this.config = data.config;
			//子节点
			this.childrens = this.formatChildrens(data.childrens);
			
			if(data.resource){
				//菜单英文名称
				this.name = data.resource.name;
				//权限编码
				this.code = data.resource.code;
				//扩展属性
				var extend = eval("("+data.resource.extend+")");
				//节点类型：leaf叶子，catalog目录，hide隐藏
				this.type = extend.type;;
				//链接地址
				this.url = extend.url;
				//配置参数
				this.params = extend.params;
			}else{
				this.name = data.id;
				this.type = "catalog";
			}
		}
		
		this.toMap = function(){
			return $model.toMap(_this);
		};
		
		this.toString = function(){
			return $model.toString(_this);
		}
	}
	
	return Navbar;
});